package cn.xlbweb.sso.service.impl;

import cn.xlbweb.sso.entity.ClientDTO;
import cn.xlbweb.sso.repository.ClientRepository;
import cn.xlbweb.sso.service.IClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: bobi
 * @date: 2019-03-24 01:50
 * @description:
 */
@Service
public class ClientServiceImpl implements IClientService {

    @Autowired
    private ClientRepository clientRepository;

    @Override
    public ClientDTO save(String token, String jessionId, String clientUrl, Integer projectId) {
        ClientDTO client = new ClientDTO(token, jessionId, clientUrl, projectId);
        return clientRepository.save(client);
    }

    @Override
    public List<ClientDTO> findByToken(String token) {
        return clientRepository.findByToken(token);
    }

    @Override
    public int deleteByToken(String token) {
        return clientRepository.deleteByToken(token);
    }
}
